﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using ThangNM_Client.SharedLibraries;
using System.Threading;

namespace ThangNM_Client
{
    static class Program
    {
        public static SplashForm splashForm = null;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            try
            {
                //Application.Run(new frmMain());
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Thread splashThread = new Thread(new ThreadStart(
                    delegate
                    {
                        splashForm = new SplashForm();
                        Application.Run(splashForm);
                    }
                ));

                splashThread.SetApartmentState(ApartmentState.STA);
                splashThread.Start();
                //frmScanInfo mainForm = new frmScanInfo();
                frmTestFacebookApp mainForm = new frmTestFacebookApp();
                mainForm.Load += new EventHandler(mainForm_Load);
                Application.Run(mainForm);
            }
            catch (Exception ex)
            {
                //(new Logs()).WriteLog_To_DB(new LogEO(ex.ToString(), ConstEx.Log_iType.EXCEPTION), false);
            }
        }

        static void mainForm_Load(object sender, EventArgs e)
        {
            try
            {
                if (splashForm == null)
                {
                    return;
                }
                splashForm.Invoke(new Action(splashForm.Close));
                splashForm.Dispose();
                splashForm = null;
            }
            catch (Exception ex)
            {
                //(new Logs()).WriteLog_To_DB(new LogEO(ex.ToString(), ConstEx.Log_iType.EXCEPTION), false);
            }
        }
    }
}
